package com.xiaotu.threadMethod;

/**
 * @Author xiaotu
 * @Description //TODO
 * @Date 2022/3/25 15:42
 * @ClassName MethodTest01
 * @Version 1.0
 **/
public class MethodTest01 implements Runnable{
    @Override
    public void run(){
        for (int i = 0; i < 10; i++) {
            synchronized (MethodTest01.class) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "正在执行");
            }
        }
    }

    public static void main(String[] args) {
        MethodTest01 methodTest01 = new MethodTest01();
        Thread 线程一 = new Thread(methodTest01, "线程一");
        Thread 线程二 = new Thread(methodTest01, "线程二");
        Thread 线程三 = new Thread(methodTest01, "线程三");
        Thread 线程四 = new Thread(methodTest01, "线程四");
        线程一.setPriority(1);
        线程一.start();
        线程二.start();
        线程三.start();
        线程四.start();
    }
}
